import { View } from '@tarojs/components'
import { ViewComponent } from './components'
import {ComponentFactory} from './index'
import { Context } from '..'
import { generateUniqueId } from '../utils/key'

export class ContainerView implements ViewComponent {
  constructor(private children: any[], private context: Context) { }
  columns() {
    // console.log('ContainerView', this.context)
    const components = []
    this.children.forEach(c => {
      components.push(ComponentFactory.createComponent(c, this.context).render())
    })
    return components
  }
  render() {
    return <View id={generateUniqueId('id-')}>{this.columns()}</View>
  }
}
